package com.penglecode.dp.behavioral.strategy;

public class DiscountContext {

	private DiscountStrategy discountStrategy;

	public DiscountContext(DiscountStrategy discountStrategy) {
		super();
		if(discountStrategy == null){
			this.discountStrategy = new MemberDiscount(); //默认为普通会员打折率
		}else{
			this.discountStrategy = discountStrategy;
		}
	}
	
	public void changeStrategy(DiscountStrategy discountStrategy){
		System.out.println(">>> 改变打折策略!");
		this.discountStrategy = discountStrategy;
	}
	
	public double getDiscountPrice(double orginalPrice){
		return this.discountStrategy.getDiscountPrice(orginalPrice);
	}
}
